package com.zh.note.huawei.twohundred.数字游戏;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * https://dream.blog.csdn.net/article/details/131232573
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int m = scanner.nextInt();
            int[] nums = new int[n];

            for (int i = 0; i < n; i++) {
                nums[i] = scanner.nextInt();
            }
            int preSum = 0;
            boolean isFind = false;
            Set<Integer> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                preSum = (preSum + nums[i]) % m;
                if (set.contains(preSum)) {
                    isFind = true;
                    break;
                }
                set.add(preSum);
            }
            System.out.println(isFind ? 1 : 0);

        }
    }
}
